package com.yanqu.road.server.manger.activity.dunhuangshiku;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.dunhuangshiku.DunHuangShiKuEventConfig;
import com.yanqu.road.entity.activity.dunhuangshiku.DunHuangShiKuMuralConfig;
import com.yanqu.road.entity.activity.dunhuangshiku.DunHuangShiKuRegionConfig;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.config.skill.SkillInfo;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.player.UserPatrons;
import com.yanqu.road.entity.player.UserPatronsSkill;
import com.yanqu.road.logic.bussiness.activity.DunHuangShiKuActivityBusiness;
import com.yanqu.road.logic.bussiness.servercenter.ActivityBussiness;
import com.yanqu.road.logic.helper.UnionActivityGroupHelper;
import com.yanqu.road.pb.dunhuangshiku.DunHuangShiKuProto;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.dunhuangshiku.DunHuangShiKuModule;
import com.yanqu.road.server.gameplayer.module.patrons.PatronsModule;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.server.manger.ForbiddenWordMgr;
import com.yanqu.road.server.manger.VipMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.activity.curio.CurioMgr;
import com.yanqu.road.server.manger.config.SkillMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.GameUnionActivityGroupMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description 敦煌石窟管理类
 * @Author cwq
 * @Data 2021/4/15 17:39
 */
public class DunHuangShiKuMgr extends TempMgr {

    /**
     * 当前活动
     */
    public static ActivityInfo activityInfo;
    /**
     * 配置项x
     */

    // 体力限用道具id
    public static List<Integer> showLimitedUseStrengthItemIdList = new ArrayList<>();
    // 限时道具使用数量上限
    public static Map<Integer, Integer> showLimitUseItemNumMap = new HashMap<>();

    public static int DUNHUANGSHIKU_SCORE_ITEM_ID = 101964;			  //敦煌石窟积分道具ID
    public static int DUNHUANGSHIKU_ENERGY_ITEM_ID = 120440;            // 敦煌石窟恢复体力道具id
    private static int DUNHUANGSHIKU_CREATE_TEAM_TIME = 2040;			  //敦煌石窟组队时长(分)
    private static int DUNHUANGSHIKU_TEAM_NAME_LENGTH_LIMIT = 6;   //敦煌石窟队伍名字字数上限
    public static int DUNHUANGSHIKU_CREATE_TEAM_NEED_INGOTS = 100;  //敦煌石窟创建队伍元宝消耗 (首次免费)
    public static int DUNHUANGSHIKU_ACTIVE_DAYS	= 3;				// 敦煌石窟活跃玩家天数
    public static int DUNHUANGSHIKU_ACTIVE_TITLE = 15;				// 敦煌石窟活跃玩家等级
    private static int DUNHUANGSHIKU_DAILY_OPEN_TIME = 10; // 敦煌石窟每日开启时间(h)
    private static int DUNHUANGSHIKU_DAILY_END_TIME = 22;  // 敦煌石窟每日结束时间(h)

    private static String DUNHUANGSHIKU_COLORING_PROP_ID = "121049|121050|121051|121052";  // 敦煌石窟颜料ID列表(红黄蓝绿)
    public static int  DUNHUANGSHIKU_MALL_KEEP_TIME  = 3600;  // 敦煌石窟商品保留时间(s)

    public static List<Integer> coloringIdList = new ArrayList<>();
    private static List<DunHuangShiKuRegionConfig> regionConfigList = new ArrayList<>(); // 区域配置
    public static Map<Integer,DunHuangShiKuRegionConfig> regionConfigMap = new ConcurrentHashMap<>(); // 区域配置

    private static List<DunHuangShiKuEventConfig> eventConfigList = new ArrayList<>();// 事件配置
    public static Map<Integer,DunHuangShiKuEventConfig> eventConfigMap = new ConcurrentHashMap<>();// 事件配置

    public static Map<Integer,DunHuangShiKuEventConfig> boxEventMap = new ConcurrentHashMap<>();// 宝箱对应的事件

    private static List<DunHuangShiKuMuralConfig> muralConfigList = new ArrayList<>(); // 壁画配置
    public static Map<Integer,DunHuangShiKuMuralConfig> muralConfigMap = new ConcurrentHashMap<>(); // 壁画配置

    private static Map<Integer, Map<Integer, MallInfo>> rmbMallInfoTypeMap = new ConcurrentHashMap<>(); // 敦煌石窟rmb礼包 k:type k:vip,v:MallInfo

    public static Set<Integer> consumeIdSet = new HashSet<>();// 通关需要的道具id  清空道具需要用

    static {
        consumeIdSet.add(120438);
        coloringIdList = StringUtils.stringToIntegerList(DUNHUANGSHIKU_COLORING_PROP_ID,"\\|");
    }

    @Override
    public boolean reload() throws Exception {
        return true;
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }


    /**
     */
    public static void reloadActivityInfo(){
        getLogger().info("reload dunHuangShiKu activity start");
        List<ActivityInfo> openActivityInfoList = NormalActivityMgr.getOpenActivityInfoList(eActivityType.CrossDunHuangShiKuActivity.getValue());
        if (openActivityInfoList.size() <= 0) {
            activityInfo = null;
            return;
        }
        activityInfo = openActivityInfoList.get(0);
        // 其他配置
        List<Integer> activityIdList = new ArrayList<>();
        activityIdList.add(activityInfo.getActivityId());
        Map<String, ActivityConfig> activityConfigMap = ActivityBussiness.getActivityConfigMap(activityIdList).get(activityInfo.getActivityId());
        if(activityConfigMap != null){
            DUNHUANGSHIKU_SCORE_ITEM_ID = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_SCORE_ITEM_ID.getName()).getIntValue();
            DUNHUANGSHIKU_CREATE_TEAM_TIME = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_CREATE_TEAM_TIME.getName()).getIntValue();
            DUNHUANGSHIKU_TEAM_NAME_LENGTH_LIMIT = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_TEAM_NAME_LENGTH_LIMIT.getName()).getIntValue();
            DUNHUANGSHIKU_CREATE_TEAM_NEED_INGOTS = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_CREATE_TEAM_NEED_INGOTS.getName()).getIntValue();
            DUNHUANGSHIKU_ACTIVE_DAYS = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_ACTIVE_DAYS.getName()).getIntValue();
            DUNHUANGSHIKU_ACTIVE_TITLE = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_ACTIVE_TITLE.getName()).getIntValue();
            DUNHUANGSHIKU_ENERGY_ITEM_ID = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_ENERGY_ITEM_ID.getName()).getIntValue();
            DUNHUANGSHIKU_DAILY_OPEN_TIME = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_DAILY_OPEN_TIME.getName()).getIntValue();
            DUNHUANGSHIKU_DAILY_END_TIME = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_DAILY_END_TIME.getName()).getIntValue();
            DUNHUANGSHIKU_MALL_KEEP_TIME = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_MALL_KEEP_TIME.getName()).getIntValue();
            DUNHUANGSHIKU_COLORING_PROP_ID = activityConfigMap.get(eActivityConfigType.DUNHUANGSHIKU_COLORING_PROP_ID.getName()).getValue();
            coloringIdList = StringUtils.stringToIntegerList(DUNHUANGSHIKU_COLORING_PROP_ID,"\\|");
            // 限时道具
            if (activityConfigMap.containsKey(eActivityConfigType.SHOW_LIMITED_USE_STRENGTH_ITEM_ID.getName())) {
                showLimitedUseStrengthItemIdList = activityConfigMap.get(eActivityConfigType.SHOW_LIMITED_USE_STRENGTH_ITEM_ID.getName()).getIntListValue("\\|");
            }
            if (activityConfigMap.containsKey(eActivityConfigType.SHOW_LIMITED_USE_ITEM_NUM.getName())) {
                Map<Integer, Integer> tempShowLimitUseItemNumMap = new HashMap<>();
                List<String> showLimitedUseItemNumParam = activityConfigMap.get(eActivityConfigType.SHOW_LIMITED_USE_ITEM_NUM.getName()).getStringListValue("\\|");
                for (String param : showLimitedUseItemNumParam) {
                    tempShowLimitUseItemNumMap.put(Integer.parseInt(param.split("=")[0]),Integer.parseInt(param.split("=")[1]));
                }
                showLimitUseItemNumMap = tempShowLimitUseItemNumMap;
            }

        }

        regionConfigList = DunHuangShiKuActivityBusiness.getDunHuangShiKuRegionConfigList(activityInfo.getActivityId());
        for(DunHuangShiKuRegionConfig item : regionConfigList){
            regionConfigMap.put(item.getId(),item);
        }

        eventConfigList = DunHuangShiKuActivityBusiness.getDunHuangShiKuEventConfigList(activityInfo.getActivityId());
        for(DunHuangShiKuEventConfig item : eventConfigList){
            eventConfigMap.put(item.getId(),item);
            if(item.getEventType() == eDunHuangShiKuEventType.Box.getValue()){
                boxEventMap.put(item.getTargetId(),item);
            }
        }

        muralConfigList = DunHuangShiKuActivityBusiness.getDunHuangShiKuMuralConfigList(activityInfo.getActivityId());
        for(DunHuangShiKuMuralConfig item : muralConfigList){
            muralConfigMap.put(item.getId(),item);
        }

        Map<Integer, Map<Integer, MallInfo>> tempMap = new ConcurrentHashMap<>();
        Map<Integer, MallInfo> mallInfoMap = NormalActivityMgr.getMallInfoTypeMap(activityInfo.getActivityId(), eShopType.DunHuangShiKuMoneyMall.getValue());
        for(MallInfo item : mallInfoMap.values()) {
            String[] str = item.getExtendParam().split("\\|");
            int type = Integer.valueOf(str[0]);
            int vip = Integer.valueOf(str[1]);
            Map<Integer,MallInfo> typeMap = tempMap.get(type);
            if(typeMap == null){
                typeMap = new HashMap<>();
                tempMap.put(type, typeMap);
            }
            typeMap.put(vip,item);
        }
        rmbMallInfoTypeMap = tempMap;
        getLogger().info("reload dunHuangShiKu activity {}, mall size {}", activityInfo.getActivityId(), rmbMallInfoTypeMap.size());

        playerReloadActivity();
        getLogger().info("reload dunHuangShiKu activity end");
    }

    private static void playerReloadActivity() {
        List<GamePlayer> playerList = GamePlayerMgr.getCopyPlayerList();
        playerList.forEach(action -> {
            action.getModule(DunHuangShiKuModule.class).sendConfigToClient();
        });
    }

    /**
     * 检查队名合法性
     * @param name
     * @return
     */
    public static short checkTeamName(String name){
        if(StringUtils.isNullOrEmpty(name)){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_TEAM_NAME_NO_EMPTY;
        }
        int nameLength = StringUtils.getStringLen(name);
        if(nameLength > DUNHUANGSHIKU_TEAM_NAME_LENGTH_LIMIT){
            return GameErrorCode.E_NAME_LENGTH_OVER;
        }
        //敏感字过滤
        if(ForbiddenWordMgr.isNickNameForbidden(name)){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_TEAM_NAME_FORBIDDEN;
        }
        return 0;
    }

    /**
     * 是否休息时间
     */
    private static boolean isRestTime() {
        int hours = DateHelper.getHours();
        return hours < DUNHUANGSHIKU_DAILY_OPEN_TIME || hours >= DUNHUANGSHIKU_DAILY_END_TIME;
    }

    /**
     * 判断是否能够进入游戏 [beginTime,endShowTime) 组队期+活动进行期+领奖期
     */
    public static int canEnterActivityEndShowTime(GamePlayer player,int activityId){
        // 等级限制
        if (!SystemOpenMgr.systemOpen(player, eSystemId.DunHuangShiKuActivity.getValue())) {
            return GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
        }
        if (DunHuangShiKuMgr.activityInfo == null || DunHuangShiKuMgr.activityInfo.getActivityId() != activityId
                || !ActivityMgr.activityInBeginTimeBetweenEndShowTime(DunHuangShiKuMgr.activityInfo)) {
            return GameErrorCode.E_ACTIVITY_OVER_TIME;
        }

        int groupId = GameUnionActivityGroupMgr.getGroupId(DunHuangShiKuMgr.activityInfo.getActivityId(), player.getUserId());
        if (groupId == UnionActivityGroupHelper.NO_GROUP_ID) {
            return GameErrorCode.E_UNION_ACTIVITY_GROUP_NO_ABLE;
        }

        return 0;
    }

    /**
     * 判断是否能够进入游戏 [beginTime,endTime) 组队期+活动进行期
     */
    public static int canEnterActivityEndTime(GamePlayer player,int activityId){
        // 等级限制
        if (!SystemOpenMgr.systemOpen(player, eSystemId.DunHuangShiKuActivity.getValue())) {
            return GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
        }
        if (DunHuangShiKuMgr.activityInfo == null || DunHuangShiKuMgr.activityInfo.getActivityId() != activityId
                || !ActivityMgr.activityInTime(DunHuangShiKuMgr.activityInfo)) {
            return GameErrorCode.E_ACTIVITY_OVER_TIME;
        }
        return 0;
    }

    /**
     * 判断是否能够加入队伍 [beginTime,endTime)
     */
    public static int canEnterActivityJoinTeamPeriod(GamePlayer player,int activityId){
        // 等级限制
        if (!SystemOpenMgr.systemOpen(player, eSystemId.DunHuangShiKuActivity.getValue())) {
            return GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
        }
        int ret = inActivityPeriod(activityId);
        if (ret != 0) {
            return ret;
        }
        return 0;
    }

    /**
     * 判断是否能够退出队伍 [beginTime,CreateTeamEndTime)
     */
    public static int canEnterActivityQuitTeamPeriod(GamePlayer player,int activityId){
        // 等级限制
        if (!SystemOpenMgr.systemOpen(player, eSystemId.DunHuangShiKuActivity.getValue())) {
            return GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
        }
        int ret = activityInCreateTeamPeriod(activityId);
        if (ret != 0) {
            return ret;
        }
        return 0;
    }


    /**
     * 判断是否能够进入游戏 [CreateTeamEndTime,endTime) 活动进行期 包括每日活动时间限制[10,22)
     */
    public static int canEnterActivitying(GamePlayer player,int activityId){
        // 等级限制
        if (!SystemOpenMgr.systemOpen(player, eSystemId.DunHuangShiKuActivity.getValue())) {
            return GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
        }
        int ret = inActivityingPeriod(activityId);
        if (ret != 0) {
            return ret;
        }
        if(isRestTime()){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_ACTIVITY_NO_IN_TIME;
        }
        return 0;
    }

    /**
     * 判断是否是在组队期[beginTime,createTeamEndTime) 组队期
     */
    private static int activityInCreateTeamPeriod(int activityId){
        if (DunHuangShiKuMgr.activityInfo == null || DunHuangShiKuMgr.activityInfo.getActivityId() != activityId) {
            return GameErrorCode.E_ACTIVITY_OVER_TIME;
        }
        int now = DateHelper.getCurrentSecond();
        long createTeamEndTime = DunHuangShiKuMgr.activityInfo.getBeginTime() + DunHuangShiKuMgr.DUNHUANGSHIKU_CREATE_TEAM_TIME * DateHelper.MINUTE_SECONDS;
        if( now < DunHuangShiKuMgr.activityInfo.getBeginTime() || now >= createTeamEndTime){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_ACTIVITY_NO_IN_TIME;
        }
        return 0;
    }

    /**
     * 判断是否是在活动期间[createTeamEndTime,endTime)  活动进行期
     */
    private static int inActivityingPeriod(int activityId){
        if (DunHuangShiKuMgr.activityInfo == null || DunHuangShiKuMgr.activityInfo.getActivityId() != activityId) {
            return GameErrorCode.E_ACTIVITY_OVER_TIME;
        }
        int now = DateHelper.getCurrentSecond();
        long createTeamEndTime = DunHuangShiKuMgr.activityInfo.getBeginTime() + DunHuangShiKuMgr.DUNHUANGSHIKU_CREATE_TEAM_TIME * DateHelper.MINUTE_SECONDS;
        if(now < createTeamEndTime || now >= DunHuangShiKuMgr.activityInfo.getEndTime()){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_ACTIVITY_NO_IN_TIME;
        }
        return 0;
    }

    /**
     * 判断是否是在活动期间[BeginTime,endTime)  组队期 + 活动进行期
     */
    private static int inActivityPeriod(int activityId){
        if (DunHuangShiKuMgr.activityInfo == null || DunHuangShiKuMgr.activityInfo.getActivityId() != activityId) {
            return GameErrorCode.E_ACTIVITY_OVER_TIME;
        }
        if(!ActivityMgr.activityInTime(DunHuangShiKuMgr.activityInfo)){
            return GameErrorCode.E_DUN_HUANG_SHI_KU_ACTIVITY_NO_IN_TIME;
        }
        return 0;
    }


    /**
     * @return
     */
    public static DunHuangShiKuProto.DunHuangShiKuActivityMsg.Builder getDunHuangShiKuActivity() {
        DunHuangShiKuProto.DunHuangShiKuActivityMsg.Builder builder = DunHuangShiKuProto.DunHuangShiKuActivityMsg.newBuilder();
        builder.setActivityId(activityInfo.getActivityId());
        for(DunHuangShiKuRegionConfig item : regionConfigList){
            builder.addRegion(builderRegionConfigEntity(item));
        }
        for(DunHuangShiKuEventConfig item : eventConfigList){
            builder.addEvent(builderEventConfigEntity(item));
        }
        for(DunHuangShiKuMuralConfig item : muralConfigList){
            builder.addMural(builderMuralConfigEntity(item));
        }
        return builder;
    }

    public static DunHuangShiKuProto.DunHuangShiKuRegionConfigEntity.Builder builderRegionConfigEntity(DunHuangShiKuRegionConfig item){
        DunHuangShiKuProto.DunHuangShiKuRegionConfigEntity.Builder builder = DunHuangShiKuProto.DunHuangShiKuRegionConfigEntity.newBuilder();
        builder.setId(item.getId());
        builder.setEnergy(item.getEnergy());
        builder.setConsumeCondition(item.getConsumeCondition());
        builder.setEventCondition(item.getEventCondition());
        builder.setEventWeight(item.getEventWeight());
        return builder;
    }

    public static DunHuangShiKuProto.DunHuangShiKuEventConfigEntity.Builder builderEventConfigEntity(DunHuangShiKuEventConfig item){
        DunHuangShiKuProto.DunHuangShiKuEventConfigEntity.Builder builder = DunHuangShiKuProto.DunHuangShiKuEventConfigEntity.newBuilder();
        builder.setId(item.getId());
        builder.setEventType(item.getEventType());
        builder.setTargetId(item.getTargetId());
        builder.setScore(item.getScore());
        builder.setBookNum(item.getBookNum());
        builder.setReward(item.getReward());
        builder.setSecurityTimes(item.getSecurityTimes());
        builder.setParam(item.getParam());
        return builder;
    }

    public static DunHuangShiKuProto.DunHuangShiKuMuralConfigEntity.Builder builderMuralConfigEntity(DunHuangShiKuMuralConfig item){
        DunHuangShiKuProto.DunHuangShiKuMuralConfigEntity.Builder builder = DunHuangShiKuProto.DunHuangShiKuMuralConfigEntity.newBuilder();
        builder.setId(item.getId());
        builder.setIcon(item.getIcon());
        builder.setStar(item.getStar());
        builder.setColour(item.getColour());
        builder.setReward(item.getReward());
        return builder;
    }

    /**
     * 玩家移除活动
     * @param player
     */
    public static void removeActivity(GamePlayer player) {
        try {
            if (DunHuangShiKuMgr.activityInfo != null && null != player) {
                if (DunHuangShiKuMgr.canEnterActivityEndShowTime(player, DunHuangShiKuMgr.activityInfo.getActivityId()) == 0) {
                    DunHuangShiKuProto.DunHuangShiKuExploreReqMsg.Builder builder = DunHuangShiKuProto.DunHuangShiKuExploreReqMsg.newBuilder();
                    builder.setActivityId(DunHuangShiKuMgr.activityInfo.getActivityId());
                    player.sendUnionActivityGroupPacket(CrossProtocol.C2_DUN_HUANG_SHI_KU_EXIT, builder, DunHuangShiKuMgr.activityInfo.getActivityId());
                }
            }
        } catch (Exception e) {
            getLogger().error("removeActivity", e);
        }
    }

    /**
     * 是否在清空道具时间内
     */
    public static boolean isActivityInClearTime() {
        if(activityInfo == null){
            return true;
        }
        long nowTime = System.currentTimeMillis() / 1000;
        return nowTime > activityInfo.getEndShowTime();
    }

    /**
     * 随机商品
     * @param dunHuangShiKuModule
     * @return
     */
    public static int randomMall(DunHuangShiKuModule dunHuangShiKuModule,GamePlayer player,int now){
        MallInfo mallInfo = null;
        List<Integer> list = new ArrayList<>(DunHuangShiKuMgr.rmbMallInfoTypeMap.keySet());
        if(list.size() > 0){
            Random random = new Random();
            int type = list.get(random.nextInt(list.size()));
            Map<Integer, MallInfo> typeMall = DunHuangShiKuMgr.rmbMallInfoTypeMap.get(type);
            int vipLevel = VipMgr.getVipLv(player.getModule(PlayerModule.class).getUserInfo().getVipExp());
            for (int i = 0; i <= vipLevel; i++) {
                MallInfo tempMallInfo = typeMall.get(i);
                if(tempMallInfo != null){
                    mallInfo = tempMallInfo;
                }
            }
        }
        int mallId = mallInfo == null ? 0 : mallInfo.getMallId();
        if(mallId != 0){
            if(now > dunHuangShiKuModule.baseData.getTouchMallTime(mallId) + DunHuangShiKuMgr.DUNHUANGSHIKU_MALL_KEEP_TIME){
                dunHuangShiKuModule.baseData.clearTouchMallTimes(mallId);
            }
            dunHuangShiKuModule.baseData.setTouchMallTime(mallId,now);
            dunHuangShiKuModule.baseData.addTouchMallTimes(mallId, 1);
        }
        return mallId;
    }

    /**
     * 获取玩家攻击力
     * @return
     */
    public static long getUserAttack(GamePlayer player){
        PatronsModule patronsModule = player.getModule(PatronsModule.class);
        long attack = 0;
        int bossTalentAddition = 0;
        for(UserPatrons item : patronsModule.getUserPatronsList()){
            attack += item.getAbility().longValue();
            for (UserPatronsSkill patronsSkill : item.getSkillList()) {
                if (patronsSkill.getType() != ePatronsSkillType.Talent.getValue()) {
                    continue;
                }
                SkillInfo skillInfo = SkillMgr.getSkillInfo(patronsSkill.getSkillId());
                if (skillInfo.getType() == eSkillType.DunHuangShiKuAttackAddRatio.getValue()) {
                    bossTalentAddition += SkillMgr.getSkillAddition(skillInfo, patronsSkill.getSkillLv());
                }
            }
        }
        bossTalentAddition += CurioMgr.getSkillAdditionBySkillType(eSkillType.DunHuangAttackBloodSkill.getValue(), player, 0);
        attack = attack + (attack * bossTalentAddition + 1000 - 1) / 1000;
        return attack;
    }

    /**
     * 获取玩家血量
     * @return
     */
    public static long getUserBlood(GamePlayer player){
        PatronsModule patronsModule = player.getModule(PatronsModule.class);
        long blood = 0;
        int bossTalentAddition = 0;
        for(UserPatrons item : patronsModule.getUserPatronsList()){
            blood += item.getAbility().longValue();
            for (UserPatronsSkill patronsSkill : item.getSkillList()) {
                if (patronsSkill.getType() != ePatronsSkillType.Talent.getValue()) {
                    continue;
                }
                SkillInfo skillInfo = SkillMgr.getSkillInfo(patronsSkill.getSkillId());
                if (skillInfo.getType() == eSkillType.DunHuangShiKuBloodAddRatio.getValue()) {
                    bossTalentAddition += SkillMgr.getSkillAddition(skillInfo, patronsSkill.getSkillLv());
                }
            }
        }
        bossTalentAddition += CurioMgr.getSkillAdditionBySkillType(eSkillType.DunHuangAttackBloodSkill.getValue(), player, 0);
        blood = blood + (blood * bossTalentAddition + 1000 - 1) / 1000;
        return blood;
    }


    public static int getCurActivityId(){
        if(activityInfo != null){
            return activityInfo.getActivityId();
        }
        return 0;
    }

    public static int getDunhuangshikuActiveTitle() {
        return DUNHUANGSHIKU_ACTIVE_TITLE;
    }

    /**
     * 获取体力限时道具
     */
    public static List<Integer> getShowLimitedUseStrengthItemIdList() {
        return showLimitedUseStrengthItemIdList;
    }

    /**
     * 获取使用道具数量上限，-1为不限制
     * @param goodsId 道具id
     */
    public static int getShowLimitedUseNum(int goodsId) {
        return showLimitUseItemNumMap.getOrDefault(goodsId, -1);
    }
}
